package com.block.channelext.factory;

import com.block.channelext.enums.ActionTypeEnum;
import com.block.channelext.service.IActionHandleService;
import com.block.channelext.service.action.AuthActionHandlerService;
import com.block.channelext.service.action.ProUvActionHandlerService;
import com.block.channelext.service.action.RegisterActionHandlerService;
import com.block.common.util.ApplicationContextUtil;

import java.util.HashMap;
import java.util.Map;

public class ActionTypeFactory {

    private static Map<String, Class<? extends IActionHandleService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(ActionTypeEnum.REGISTER.getValue(), RegisterActionHandlerService.class);
        serviceMap.put(ActionTypeEnum.AUTH.getValue(), AuthActionHandlerService.class);
        serviceMap.put(ActionTypeEnum.PRO_UV.getValue(), ProUvActionHandlerService.class);
    }

    public static IActionHandleService getService(String filterKey){
        if (serviceMap.containsKey(filterKey)){
            Class<? extends IActionHandleService> aClass = serviceMap.get(filterKey);
            return ApplicationContextUtil.getBean(aClass);
        }
        return null;
    }


}
